Java JavaScript Python C# C C++ Go Kotlin PHP Swift R Ruby TypeScript Scala SQL Perl rust VisualBasic Matlab Julia

Types of Inheritance

Inheritance types

Inheritance is a fundamental feature of Java’s Object-Oriented Programming (OOP) that allows one class to inherit the properties and behavior of another class. Java supports four types of inheritance. Multiple inheritance is not supported in Java through class. However, it can be achieved through interfaces. single inheriatance Single Inheritance: In single inheritance, a subclass is derived from only one superclass. It inherits the properties and behavior of a single parent class. multi-level inheriatance Multi-level Inheritance: In multi-level inheritance, a class is derived from a class which is also derived from another class. For example, if class C extends class B, and class B extends class A, then this is a multilevel inheritance. hierarchial inheriatance Hierarchical Inheritance: In hierarchical inheritance, one class serves as a superclass (base class) for more than one subclass. hybrid inheriatance Hybrid Inheritance: Hybrid inheritance is a combination of multiple and multi-level inheritance. It’s important to note that this type of inheritance can be achieved through interfaces. multiple inheriatance Note: Multiple inheritance (where a class can directly inherit from more than one superclass) is not supported in Java through class. However, it can be achieved through interfaces.

  📌TAGS

★Class ★ Method ★ Object ★ java ★ oops ★ inheritance ★ inheritance types

Tutorials